<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/main.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/news-list.css" />
	</head>

	<body>
		<div class="head">
			<img class="mui-action-back" src="../../images/all-left.png" alt="">
			<p>资讯列表</p>
		</div>

		<div class="content" id="content">
			<!--<div class="list">
    		<p class="list-title">
    			<span>哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈</span>
    			<span></span>
    		</p>
    		<p class="list-message">
    			<span id="list-date">2017-10-2</span>&nbsp;
    			<span id="list-num">1000人阅读</span>
    		</p>
    		<div class="pic"></div>-->
			<!--</div>-->
			<!--<p class="more">点击加载更多</p>-->
		</div>

		<script src="../../libs/mui.min.js"></script>
		<script src="../../js/jquery-3.1.1.min.js"></script>
		<script src="../../js/url.js"></script>
		<script type="text/javascript">
			//热点咨询列表
			newList();
			var page = 1;

			function newList() {
				$.ajax({
						url: ur + 'rest/informationController/list',
						type: 'GET',
						dataType: 'json',
						headers: {
							"X-Token": localStorage.token
						},
						data: {
							page: page
						}
					})
					.done(function(data) {
						if(data.meta.code == 'S002') {
							var totalPage = Math.ceil(data.data.total / 10);
							var info = data.data.list;
							var i = 0;
							var s = info.length;
							if(totalPage >= page) {
								for(i; i < s; i++) {
									var list = $('<div class="list" ids=' + info[i].id + '>' +
										'<p class="list-title">' +
										'<span>' + info[i].title + '</span>' +
										'<span></span>' +
										'</p>' +
										'<p class="list-message">' +
										'<span id="list-date">' + info[i].uploadTime + '</span>&nbsp;' +
										'<span id="list-num">' + info[i].readNumber + '人阅读</span>' +
										'</p>' +
										'<div class="pic" style="background-image: url(' + ur + data.data.list[i].image + ')" ></div>' +
										'<div');
									$('#content').append(list);
								}
							}
							var more = '<p class="more">点击加载更多</p>';
							if(page < totalPage && $('.more').length == 0) {
								$('#content').append(more);
								$('.more').text('点击加载更多');
								$('#content').on('tap', '.more', function() {
									page++;
									$(this).remove()
									newList();
								})
							} else {
								$('#content').append(more);
								$('.more').text('已无更多');
							}
						} else {
							mui.toast(data.meta.message);
						}
					})
			}

			$('#content').on('tap', '.list', function() {
				localStorage.news_id = $(this).attr('ids');
				href('news.html', 'news');
			})
		</script>
	</body>

</html>